package com.zbj.zuul;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * ZbjZuulController
 * 源码包含这个类 ZuulController
 *
 * @author weigang
 * @create 2019-08-13
 **/
@RestController
public class ZbjZuulController {

    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("/hello")
    public String hello(@RequestParam(defaultValue = "tom", required = false) String tom) {
        return restTemplate.getForObject("http://zbj-provider/provider/hello/" + tom, String.class);
    }

    @RequestMapping("/local")
    public String local(@RequestParam(defaultValue = "local", required = false) String local) {
        return local;
    }

    @RequestMapping("/local/hello")
    public String localHello(@RequestParam(defaultValue = "localHello", required = false) String localHello) {
        return localHello;
    }

}